//储存层核心代码
const STRINGTYPE ="string"


//保存localStorage

export const setStorage =(key,data)=>{
    if(!key){
        return
    }
    if(typeof(data)!=STRINGTYPE){
        data=JSON.stringify(data)
    }
    localStorage.setItem(key,data)
}

//读取localStorage

export const getSorage =(key)=>{
    if(!key){
        return
    }
    var data =localStorage.getItem(key)
    if(data){
        return  JSON.parse(data)
    }
    return null
}

//删除localStorage

export const removeStorage =(key)=>{
    if(!key){
        return
    }
    localStorage.removeItem(key)
}